<%@codepage="65001"%>
<%session.codepage="65001"%>

<!-- #include virtual=/inc/dbConn.asp -->
<!--METADATA TYPE= "typelib" NAME= "ADODB Type Library" FILE="C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll" -->
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">	  
<%
	Response.CharSet = "utf-8" 
	Response.AddHeader "Pragma","no-cache"
	Response.AddHeader "Expires","0"

	If Request.Cookies("S_uid") = "" Then 
		response.write "Session Off!!"
		response.end
	End If 
	
	Function aFieldValue(Q)		' 한개의 필드의 값을 구하는 함수
		Set Rsf=Server.CreateObject("ADODB.RecordSet")
		Rsf.open Q, dbCon
		if Rsf.eof or Rsf.bof then
			aFieldValue = ""
		Else
			aFieldValue = Rsf(0)				
		End If
	End Function	

	Set upload = server.CreateObject("DEXT.FileUpload")
	Set fs = CreateObject("Scripting.FileSystemObject")
	upload.DefaultPath = server.MapPath("/files/")
	upload.CodePage = 65001

	If IsObject(upload) = False Then
		response.write("DEXTUpload가 생성이 되지 않았습니다.")
		response.End
	End If
	subjects = Replace(upload("subjects"),"'","''")
	context = Replace(upload("context"),"'","''")
	context = Replace(context,"</P>" & vbcrlf & "<P>","<br>")
'	Response.write "<META http-equiv='Content-Type' content='text/html; charset=utf-8'>"
'	Response.write Len(context) & "////" & context

	sender = upload("sender")
	noticeFlag = upload("noticeFlag")
	seq = upload("seq")
	
	If seq = "" Then 
		seq = 0
	End if 
	
	fileNm = upload("uFile").FileName  
	If fileNm = "" And isFile <> "" Then 
		fileNm = isFile
	End If 
	
	flag = "Y"
		
	'response.end
	If mode = "del" Then 
	Else '쓰기 or 수정
		
		files = upload("uFile").FileName  
		If files <> "" Then 
			files = upload("uFile").Save( ,false)
		End If 

		SQL = "exec spFreeBoard " & _
				"'" & subjects &"'" & _
				", '" & context &"'" & _
				", '" & sender &"'" & _
				", '" & noticeFlag &"'" & _
				", '" & fileNm &"'" & _
				", '" & flag &"'" & _
				", '" & seq &"'" 
		dbCon.execute SQL

		Response.write "<script>" 
		Response.write "	alert('저장되었습니다.');"
		Response.write "	opener.parent.fnShowBbs('" & seq &"','','stay');"
		Response.write "	self.close();"
		Response.write "</script>"

		Response.End
	End If 
%>
<%session.codepage="949"%>
